public class PrepareRequest {

	public synchronized String prepareHeader(String messageType) {

		return messageType + Properties.MSG_SEPERATOR
				+ SelfInfo.nodeTriple.nodeID + Properties.MSG_SEPERATOR
				+ SelfInfo.nodeTriple.ip + Properties.MSG_SEPERATOR
				+ SelfInfo.nodeTriple.port;
	}

	public synchronized void pingSomeOne(NodeTriple nodeTriple) throws Exception {

		String header = prepareHeader(Properties.PING_HEADER);
		SendingService.getSendingService().send(header, nodeTriple.ip,
				nodeTriple.port);

		// Add to the list to wait for response.
		WaitingQueueForPongEntry entry = new WaitingQueueForPongEntry();
		entry.setNodeTriple(nodeTriple);
		entry.setTimestamp(System.currentTimeMillis());
		WaitingQueueForPong.addAnEntry(entry);

	}

	public synchronized void sendFindNodeRequest(String IdToFind, NodeTriple nodeTriple)
			throws Exception {

		new BucketOperations().addTripleIntoBucket(nodeTriple);
		String message = prepareHeader(Properties.FIND_NODE_REQUEST_HEADER)
				+ Properties.MSG_SEPERATOR + IdToFind;

		SendingService.getSendingService().send(message, nodeTriple.ip,
				nodeTriple.port);

		// Add to the waiting list for response.
		WaitingQueueForFindNodeResponseEntry entry = new WaitingQueueForFindNodeResponseEntry();

		entry.setNodeTriple(nodeTriple);
		entry.setTimestamp(System.currentTimeMillis());
		
		WaitingQueueForFindNodeResponse.addAnEntry(entry);
	}

}
